function renderHeader(Xlr8PageTemplate, showHeaderLinks = true) { if (isTest) { Xlr8PageTemplate.Header.setNonProductionEnvironmentMessage( "TEST ENVIRONMENT" ); } let headerMenu = []; if (showHeaderLinks) { let profile = { id: "profile-menu", icon: "person", label: profileMenuText, displayMode: 0, childItems: [] }; headerMenu.push(profile); if (userInfo) { profile.childItems.push({ id: "user-info", label: userInfo, displayMode: 2, childItems: [] }); } if (isUsingPassport) { const userProfileElement = { id: "my-profile-link", icon: "account_circle", url: userProfileLink, label: myProfileLinkText, openInTab: true, displayMode: 0 }; addElementToProfile(profile, userProfileElement); } if (signOffEnabled) { const signOffElement = { id: "sign-off-link", icon: "logout", url: signOffUrl, label: signOutText, displayMode: 0 }; addElementToProfile(profile, signOffElement); } } Xlr8PageTemplate.Header.setMenu(headerMenu); Xlr8PageTemplate.Header.render(); } function addElementToProfile(profile, element) { if (userInfo) { profile.childItems[0].childItems.push(element); } else { profile.childItems.push(element); } }